package es.realtimesystems.simplemulticast;

import java.lang.*;
import java.util.*;
import java.net.*;
import java.util.TreeMap;
import java.util.Iterator;

/**
 * Clase de prueba TPDUCGL
 */
public class PruebaTPDUCGL
{
 public PruebaTPDUCGL ()
 {

    Log.setDepuracion(true);
    Log.setNivelDepuracion(Log.TPDU_CGL | Log.TPDU);

   try
   {
    Address dirMcast = new Address("224.2.2.2",2000);


    Log.log(null,"Crear el socket...");


    SocketPTMFImp socket = new SocketPTMFImp(dirMcast,null,(byte)8,PTMF.PTMF_NO_FIABLE,null,null,null);

    Buffer ip = new  Buffer(4);
    ip.addByte((byte)192,0);
    ip.addByte((byte)168,1);
    ip.addByte((byte)0,2);
    ip.addByte((byte)2,3);

    TPDUCGL tpduCGL =  TPDUCGL.crearTPDUCGL(socket /*SocketPtmf*/,
      (byte)PTMF.TPDU_CGL_BUSCAR_GRUPO_LOCAL /* byte SUBTIPO*/,
      (byte)1 /*byte TTL */,
      (short)0 /* short METRICA*/,
      true /* boolean flagIP */,
      3 /* N_MAX_SOCKETS*/,
      5 /* N_SOCKETS*/,
      (IDGL)null,
      (TreeMap)null /* treeMapIDGL */,
      (TreeMap)null /* treeMapID_SOCKET */,
      new ID_Socket(new IPv4(ip),23) /* ID_SOCKET */
      );


    Log.log("","Creado, construir");
    Buffer buf = tpduCGL.construirTPDU();

    for(int i = 0;i < buf.getMaxLength(); i++)
      Log.log(""+i,": "+buf.getByte(i));

    TPDUCGL tpduCGL2 = TPDUCGL.parseBuffer(buf);

   }

   catch(ParametroInvalidoExcepcion e)
   {
      Log.exit(-1);
   }
   catch(PTMFExcepcion e)
   {
      Log.exit(-1);
   }

   catch(UnknownHostException e)
   {
     Log.exit(-1);
   }

 }


 public static void main (String args[])
 {
  new PruebaTPDUCGL ();
 }

}



